package cn.hxzy.service.impl;

import cn.hxzy.client.HomeworkClient;
import cn.hxzy.domain.Task;
import cn.hxzy.domain.TaskManager;
import cn.hxzy.mapper.UserMapper;
import cn.hxzy.service.HomeworkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class HomeworkServiceImpl implements HomeworkService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private HomeworkClient homeworkClient;

    @Override
    public List<TaskManager> getUserIdByUserName(String userName) {
        List<Integer> userId = userMapper.getUserIdByUserName(userName);
        List<TaskManager> list=new ArrayList<TaskManager>();
        for (Integer i : userId) {
            List<TaskManager> taskList = homeworkClient.getTaskList(i);
            for (TaskManager task : taskList) {
                list.add(task);
            }
        }
        return list;
    }
}
